//
//  MyMessageViewController.m
//  LoveBeeProject
//
//  Created by 沈腾飞 on 2017/1/5.
//  Copyright © 2017年 斯芬克斯. All rights reserved.
//

#import "MyMessageViewController.h"

@interface MyMessageViewController ()
@property(nonatomic,strong)UIView *systemview;
@property(nonatomic,strong)UIView *userview;
@end

@implementation MyMessageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    UISegmentedControl *message = [[UISegmentedControl alloc]initWithItems:@[@"系统消息",@"用户消息"]];
    message.selectedSegmentIndex = 0;
    for(int i = 0; i < message.numberOfSegments;i++)
    {
        [message setWidth:80 forSegmentAtIndex:i];
    }
    self.navigationItem.titleView = message;
    
    [message addTarget:self action:@selector(selected:)forControlEvents:UIControlEventValueChanged];
    UIView *systemview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    systemview.backgroundColor = [UIColor cz_colorWithHex:0xefefef];
    UIImage *image = [UIImage imageNamed:@"v2_my_message_empty"];
    UIImageView *imageView = [[UIImageView alloc]initWithImage:image];
    [systemview addSubview:imageView];
    UILabel *messageLabel = [[UILabel alloc]init];
    messageLabel.text = @"暂无消息";
    [systemview addSubview:messageLabel];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(systemview.mas_centerX).offset(0);
        make.centerY.equalTo(systemview.mas_centerY).offset(-120);
    }];
    [messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(systemview.mas_centerX).offset(0);
        make.top.equalTo(imageView.mas_bottom).offset(10);
    }];
    self.systemview = systemview;
    [self.view addSubview:systemview];
    
    UIView *userview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    userview.backgroundColor = [UIColor whiteColor];
    self.userview = userview;
    [self.view addSubview:userview];

}
-(void)selected:(id)sender
{
    UISegmentedControl *control = (UISegmentedControl*)sender;
    switch (control.selectedSegmentIndex) {
        case 0:
            self.userview.hidden = NO;
            self.systemview.hidden = YES;
            break;
        case 1:
            self.userview.hidden = YES;
            self.systemview.hidden = NO;
            
            break;
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
